package org.example.JUC.waitTest.producerAndConsumer;

import org.example.JUC.Tools.MyBlockingQueue;

/**
 * @description:
 * @author: farprt
 * @create: 2022-08-20 20:10
 **/
public class Consumer extends Thread{
    MyBlockingQueue<String> queue;
    public Consumer(MyBlockingQueue<String> queue){
        this.queue=queue;
    }

    @Override
    public void run() {
        while(true){
            try {
                String task=queue.take();
                System.out.println("handle task"+task);
                Thread.sleep((int) Math.random()*100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}